package run.microservice.stock.model.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author lunfangyu
 */
@Data
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = -225831098107895806L;

    /** 主键ID*/
    @Id(keyType = KeyType.Generator, value = KeyGenerators.flexId)
    private Long id;

    /**
     * 为解决唯一索引的问题，已删除状态采用deleted=id表示
     * 0，未删除；deleted=id，已删除
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Column(isLogicDelete = true)
    private Integer deleted;

    /** 创建人 */
    private Long createdBy;

    /** 创建时间 */
    @Column(onInsertValue = "now()")
    private LocalDateTime createdTime;

    /** 修改人 */
    @Column
    private Long updatedBy;

    /** 修改时间 */
    @Column(onUpdateValue = "now()")
    private LocalDateTime updatedTime;

}
